package algotithm.leetcode.string.test171;

/**
 * @author zhouyanxiang
 * @Date 2021-02-2021/2/1-13:59
 * @Title 171. Excel表列序号
 */
public class Solution {


    public static void main(String[] args) {
        String s = "AB";
        Solution solution = new Solution();
        int number = solution.titleToNumber(s);
        System.out.println(number);
    }

    public int titleToNumber(String s) {
        int res = 0;
        for (int i = 0; i < s.length(); i++) {
            int num = s.charAt(i) - 'A' + 1;
            res = res * 26 + num;
        }
        return res;
    }
}
